#include "MyQueue.h"
using namespace std;
#include <iostream>
MyQueue::MyQueue(int capacity){
    queue=new int[capacity];
    tail=0;
    head=0;
    size=0;
    this->capacity=capacity;
}
MyQueue::~MyQueue(){

}
void MyQueue::enqueue(int val){
    if (isFull())
    {
        cout<<"队列已满,无法插入新元素"<<endl;
        return;
    }
    queue[tail%capacity]=val;
    tail++;  
    tail=tail%capacity;
    size++;
}
void MyQueue::traverse(){
    for (int i = 0; i < capacity; i++)
    {
        cout<<queue[i]<<"-";
        /* code */
    }
    
}
int MyQueue::dequeue(){
   if (isEmpty())
   {
       cout<<"队列为空值,无法取出";
       return -1;
       /* code */
   }
   int val = queue[head];
    head++;
    head=head%capacity;
    size--;
    return val;
}
bool MyQueue::isFull(){
    return size==capacity?true:false;
}
bool MyQueue::isEmpty(){
    return size==0?true:false;
}